package com.zhzh.sc.demo.juc.lock;

/**
 * @author: dasouche
 * @date: 2021-03-10 14:15
 **/
public class VolatileDemo {
    /*volatile*/ static boolean flag = true;

    private void service() {
        System.out.println("service start");
        while (flag) {

        }
        System.out.println("service end");
    }

    public static void main(String[] args) throws InterruptedException {
        VolatileDemo v = new VolatileDemo();
        new Thread(v::service, "thread-1").start();
        Thread.sleep(1000);
        flag = false;
    }
}
